package com.central.operate.dao;

import com.central.operate.dto.ChartParams;
import com.central.operate.model.LoginCreateTime;
import com.central.operate.model.LoginInfo;
import com.central.operate.model.OperateRecord;
import com.central.operate.vo.RegisterCountChartVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface RegisterDao {
    int registerCount(Map<String, Object> params);

    List<LoginInfo> findRegisterList(Map<String, Object> params);

    List<Integer> findRegisterCount();

    List<LoginCreateTime> findRegister(Map<String, Object> params);

//    @Select("SELECT UNIX_TIMESTAMP(startTime) * 1000 millisecond, SUM(register) count FROM operate_record WHERE DATE_SUB(#{start_time}, INTERVAL #{consecutive_day} DAY) < date(startTime) AND #{start_time} >= date(startTime) GROUP BY DATE(startTime),HOUR (startTime) div #{interval_hour} ORDER BY millisecond")
//    List<RegisterCountChartVO> listRegisterCount(Map<String, Object> params);

    @Select("SELECT UNIX_TIMESTAMP(startTime) * 1000 millisecond, SUM(register) count FROM operate_record WHERE DATE_SUB(#{startTime}, INTERVAL #{consecutiveDay} DAY) < date(startTime) AND #{startTime} >= date(startTime) GROUP BY DATE(startTime),HOUR (startTime) div #{intervalHour} ORDER BY millisecond")
    List<RegisterCountChartVO> listRegisterCount(ChartParams chartParams);
}
